package com.bg.print.config.securityconfig;

import com.alibaba.fastjson2.JSON;
import com.bg.print.utils.R;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import java.io.IOException;

/**
 * @program: bg-print-java
 * @description: 注销成功
 * @author: liuxvru
 * @create: 2024-04-03 11:02
 **/

public class MyLogoutSuccessHandler implements LogoutSuccessHandler {

    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        //转换成json字符串
        String json = JSON.toJSONString(R.ok("注销成功"));
        //返回响应
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().println(json);
    }
}
